﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Text; 
using T.FAS.Runtime.Metadata.Entity;
using T.FAS.Runtime.Base.Entity;

namespace T.FAS.Runtime.DataModel.Plugin
{
    /// <summary>
    /// SQL Item
    /// </summary>
    public class SQLItem 
    {
        /// <summary>
        /// 元数据ID
        /// </summary>
        public string MetaDataID { get; set; }
        /// <summary>
        /// 元数据Code
        /// </summary>
        public string MetaDataCode { get; set; }
        /// <summary>
        /// 元数据类型
        /// </summary>
        public string MetaDataType { get; set; }
        /// <summary>
        /// SQL执行的配置项
        /// </summary>
        public string ConfigKey { get; set; }
        /// <summary>
        /// 数据库类型
        /// </summary>
        public DatabaseType DatabaseType { get; set; }
        /// <summary>
        /// SQL内容
        /// </summary>
        public string SQL { get; set; }
        /// <summary>
        /// 支持参数变量替换
        /// </summary>
        public List<IDbDataParameter> Parameters { get; set; } = new List<IDbDataParameter>();
        /// <summary>
        /// 数据源
        /// </summary>
        public string DataSource { get; set; }
        /// <summary>
        /// SQL语句类型 DML, DDL
        /// </summary>
        public SQLType SQLType  {get;set;}
        /// <summary>
        /// SQL语句操作类型 CRUD
        /// </summary>
        public CRUDType CRUDType { get; set; }
        /// <summary>
        /// 是否可以重复执行
        /// </summary>
        public bool IsCanRepeat { get; set; }

        public SQLItem Clone()
        {
            return this.MemberwiseClone() as SQLItem;
        }
    }

    public enum SQLType
    {
        DDL,
        DML,
    }

    public enum CRUDType
    {
        CREATE,
        RETRIEVE,
        UPDATE,
        DELETE,
    }
}
